#ifndef LINKER_OPERATOR_HPP
#define LINKER_OPERATOR_HPP

//------------------------------------------------------------------------------
// Fichier d'entête utilisés
//------------------------------------------------------------------------------
#include "Operator.hpp"
#include "Gradiant.hpp"
#include "BinaryImage.hpp"
#include "Outline.hpp"
#include "OutlineContainer.hpp"

namespace ImageAnalysis
{

//----------------------------------------------------------------------
//
//----------------------------------------------------------------------
class LinkerOperator : public Operator
{
public:
		//----------------------------------------------------------------------
		// Structure
		//----------------------------------------------------------------------
		
		//----------------------------------------------------------------------
		// Constructeur
		//----------------------------------------------------------------------
		LinkerOperator( Gradiant* gradiant, BinaryImage* refinedImage, OutlineContainer* outlines );
		
		//----------------------------------------------------------------------
		// Destructeur
		//----------------------------------------------------------------------
		virtual ~LinkerOperator();
		
		//----------------------------------------------------------------------
		// Méthode 
		//----------------------------------------------------------------------
		virtual void Process( );

		//----------------------------------------------------------------------
		// 
		//----------------------------------------------------------------------	
		void RecursiveExploration( int currentIndex, Outline* outline, OutlineContainer* container, BinaryImage* temporaryImage, bool direct, bool indirect );

private:
		//----------------------------------------------------------------------
		// Permet de determiner si un ensemble de point appartient au contour
		//----------------------------------------------------------------------
		int belongOutline( BinaryImage* temporaryImage, Layer::PixelNeighborHood& neighborHood, Orientation::TOrientation* orientation, bool* belongCandidate  );

		//----------------------------------------------------------------------
		// Permet de traiter un ensemble de point qui appartiennent au contour
		//----------------------------------------------------------------------
		int ExploreOutline( BinaryImage* temporaryImage, int numberOfCandidate, Layer::PixelNeighborHood& neighborHood, Orientation::TOrientation* orientation, bool* possibleCandidate, OutlineContainer* container );

		//----------------------------------------------------------------------
		//
		//----------------------------------------------------------------------
		BinaryImage* currentRefinedImage;
		Gradiant* currentGradiant;
		OutlineContainer* currentOutlinesContainer;
		//----------------------------------------------------------------------
		// Constructeur par copie et oprérateur d'affectation en privée pour
		// interdire leur utilisation
		//----------------------------------------------------------------------
		LinkerOperator( const LinkerOperator& copy);
		LinkerOperator& operator=( const LinkerOperator& copy );
};

}

#endif //LINKER_OPERATOR_HPP
